package week2;

import java.util.Iterator;

/**
 * Created by YanChenDeng on 2016/11/17.
 */
public class ArrayQueue<Item> extends AbstractQueue<Item> {
    private ResizableArray<Item> array;
    public ArrayQueue(){
        array = new ResizableArray<Item>(1);
    }

    @Override
    public void enqueue(Item item) {
        array.add(item);
    }

    @Override
    public Item dequeue() {
        return array.removeAt(0);
    }

    @Override
    public boolean isEmpty() {
        return array.size() == 0;
    }

    @Override
    public int size() {
        return array.size();
    }

    @Override
    public Iterator<Item> iterator() {
        return array.iterator(ResizableArray.ITERATOR_QUEUE);
    }
}
